package com.atguigu.composite;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class College extends OrganizationComponent {
    List<OrganizationComponent> components = Collections.synchronizedList(new ArrayList<>());

    public College(String name, String description) {
        super(name, description);
    }

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        components.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        components.remove(organizationComponent);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDescription() {
        return super.getDescription();
    }

    @Override
    protected void print() {
        System.out.println("-----" + getName() + "-----");

        for (OrganizationComponent component : components) {
            component.print();
        }
    }
}
